package com.cn.http;

import com.cn.http.impl.*;

import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.HashMap;
import java.util.Map;

/**
 * &#064;Time 2024 八月 星期五 19:10
 *
 * @author ShangGuan
 */
public class HttpRequestTest2 {
    public static void main(String[] args) throws IOException {
        Map<String, Object> objectObjectHashMap = new HashMap<>();
        objectObjectHashMap.put("Token","你好");
        SimpleHttpParam simpleHttpParam = new SimpleHttpParam();
        simpleHttpParam.setBody(objectObjectHashMap);
        Http http = new Http(new URL("http://localhost:10222"));
        http.addRequestHeader("content-type", "application/json");
        SimpleHttpRequest simpleHttpRequest = new SimpleHttpRequest(http);
        HttpConfig simpleHttpConfig = new SimpleHttpConfig();
        simpleHttpConfig.setReadTimeout(1);
        simpleHttpConfig.setConnectTimeout(10);
        simpleHttpRequest.setConfig(simpleHttpConfig);
        HttpResponse post = simpleHttpRequest.post();
        System.out.println(post.getStatus());
        System.out.println(post.getContent());
    }
}
